//
//  LocalCollectionViewCell.m
//  Qyer
//
//  Created by 赵宇 on 15/9/18.
//  Copyright (c) 2015年 赵宇. All rights reserved.
//

#import "LocalCollectionViewCell.h"
#import "BaseHeader.h"
#define wid self.contentView.frame.size.width
#define hei self.contentView.frame.size.height
@implementation LocalCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor colorWithRed:248./255 green:248./255 blue:248./255 alpha:1];
         self.pic = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, wid, hei/2)];
        [self.contentView addSubview:self.pic];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, hei/2, wid, hei/3)];
        self.titleLabel.numberOfLines = 2;
        self.titleLabel.font = [UIFont systemFontOfSize:14.];
        [self.contentView addSubview:self.titleLabel];
 
        
        self.priceoffLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, self.titleLabel.frame.size.height+hei/3*1.4 , wid/3, hei/6)];
        
        self.priceoffLabel.textColor = [UIColor grayColor];
        self.priceoffLabel.font = [UIFont systemFontOfSize:13.];
        [self.contentView addSubview:self.priceoffLabel];
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(wid/3*1.7, self.titleLabel.frame.size.height+hei/3*1.4, wid/2, hei/6)];
        self.priceLabel.font = [UIFont systemFontOfSize:14.];
        self.priceLabel.textColor = [UIColor redColor];
        [self.contentView addSubview:self.priceLabel];
        
    }
    return self;
}
-(void)setValueWithModel:(LocalModel *)localmod
{
    NSURL *url = [NSURL URLWithString:localmod.photo];
    
    [self.pic sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
    self.titleLabel.text = localmod.title;
    self.priceoffLabel.text = localmod.priceoff;
    NSString *str =[localmod.price substringWithRange:NSMakeRange(4, localmod.price.length - 4 - 7)];
    NSString *string = [NSString stringWithFormat:@"%@元起",str];
    self.priceLabel.text = string;
}
@end
